import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

public class LeapYear extends TypeSafeMatcher<Integer> {

    @Override
    protected boolean matchesSafely(Integer year) {
        if (year < 1) {
            return false;
        }
        return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
    }

    @Override
    public void describeTo(Description description) {
        description.appendText("a leap year");
    }

    public static LeapYear leapYear() {
        return new LeapYear();
    }
}